	//<!--

	/* escapeOverlay's construction is a bit hard to grasp. It is needed to be able to
	stop the event listener. See the prototype API docs for more information:
	http://www.prototypejs.org/api/event
	*/
	
	var dialogDiv;
	var window_height;
	var window_width;
	
	var escapeOverlay = {
		fx: function(e) 
		{
			// To make script compatable with both MSIE and Firefox
			var kC  = (window.event) ? event.keyCode : e.keyCode;
			var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE;
			
			// If keypressed is escape and the new entry field is empty
			if(kC==Esc)// && ($F('newvalue') == '' || $F('newvalue') == null) )
				closeDialogue();
			//else if(kC==Esc && window.confirm('Are you sure you wish to close the dialogue box?') )
				//closeDialogue();
		}
	}

	// Save in cache (to be able to stopObserving() it), see Prototype API docs for more info:
	// http://www.prototypejs.org/api/event
	escapeOverlay.bfx = escapeOverlay.fx.bindAsEventListener(escapeOverlay);

	function setOverlaySize() {
		if (typeof window.innerWidth != 'undefined') {
			viewportheight = window.innerHeight;
		} else {
			viewportheight = document.documentElement.clientHeight;
		}
		if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
			blanket_height = viewportheight;
		} else {
			if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
				blanket_height = document.body.parentNode.clientHeight;
			} else {
				blanket_height = document.body.parentNode.scrollHeight;
			}
		}
		$('overlay').style.height = blanket_height + 'px';
		//alert(document.body.parentNode.scrollTop);
	}
	
	// loadPopup shows the overlay and dialogue box
	function loadPopup(popUpDiv,width,height)
	{
		
				
	    dialogDiv = popUpDiv;
		setOverlaySize();
		// Show the overlay (disables rest of page)
		showOverlay();

		if (typeof window.innerWidth != 'undefined') {
			window_width = window.innerWidth;
			window_height = window.innerHeight;
		} else {
			window_width = document.documentElement.clientWidth;
			window_height = document.documentElement.clientHeight;
		}
		window_height2 = document.body.parentNode.scrollTop;

		$(dialogDiv).style.position = 'absolute';
		$(dialogDiv).style.textAlign = 'left';
		//$(dialogDiv).style.marginTop = (window_width-width)/2+'px';
		//$(dialogDiv).style.marginLeft = (window_height-height)/2+'px';
		$(dialogDiv).style.backgroundColor = '#f0f6da';
		$(dialogDiv).style.width = width+'px';
		$(dialogDiv).style.height = height+'px';
		$(dialogDiv).style.padding = 1+'px';
		$(dialogDiv).style.border = '1px solid #FFFFFF';
		$(dialogDiv).style.left = (window_width-width)/2+'px';
		$(dialogDiv).style.top = (window_height-height)/2+window_height2+'px';
		$(dialogDiv).style.zIndex = '2000';
		
		// Show dialogue and focus on newvalue
		$(dialogDiv).show();
	}
	 
	// Shows the overlay and starts the ESCAPE event listener
	function showOverlay()
	{
		$('overlay').show();
		
		Event.observe(document, 'keypress', escapeOverlay.bfx );
	}

	// Hides the overlay and stops the ESCAPE event listener
	function hideOverlay()
	{
		$('overlay').hide();
		
		Event.stopObserving(document, 'keypress', escapeOverlay.bfx );
	}

	// Closes the dialogue box, resets it and hides the overlay
	function closeDialogue()
	{
		hideOverlay();
		
		// Hide dialogue
		$(dialogDiv).hide();
		
	}

	/* Event handler for onKeyPress for the newvalue field. Enables the use of the ENTER (RETURN)
	key when adding a new entry in the dialogue box */
	function enterKey(event, field)
	{
		// If the event key pressed was a return (code 13)
		if (event.which == 13 || event.keyCode == 13)
			addEntry(field.value);
	}

	//-->	